package br.com.mubi.review;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

public class NotaDAOHibernate implements NotaDAO {

	private Session session;
	
	public void setSession(Session session) {
		this.session = session;
	}
	
	@Override
	public void salvar(Nota nota) {
		this.session.persist(nota);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Nota> listarPorFilmeId(long idFilme) {
		Criteria criteria = this.session.createCriteria(Nota.class);
		criteria.add(Restrictions.eq("filme.id", idFilme));		
		return criteria.list();
	}

}
